import service from "../../utils/service";
// 获取用户信息
const getUserInfo = () => {
  return service({
    method: "get",
    url: "/ranstore/user/getUserInfo",
  });
};
/**
 * post: 修改用户信息
 * path: /ranstore/user/updateUserInfo
 * param: avatar - {string} 头像
 * param: nickname - {int} 昵称
 * param: phone - {int} 电话号码
 */
const updateUserInfo = (data) => {
  return service({
    method: "post",
    url: "/ranstore/user/updateUserInfo",
    data
  });
};
// 获取oss签名
const getPostObjectParams = (data) => {
  return service({
    method: "get",
    url: "https://www.iranboss.com/oss/getPostObjectParams",
    data
  });
};


/**
 * post: 获取手机号信息
 * path: /ranstore/user/getPhoneInfo
 * param: code - {int} 小程序code，必填
 */
const getPhoneInfo = (data) => {
  return service({
    method: "post",
    url: "/ranstore/user/getPhoneInfo",
    data
  });
};

/**
 * post: 发送验证码
 * path: /ranstore/user/sendVerificationCode
 * param: phone - {string} 电话号码
 */
const sendVerificationCode = (data) => {
  return service({
    method: "post",
    url: "/ranstore/user/sendVerificationCode",
    data
  });
};

/**
 * post: 小程序登录,登录后接口调用除了头部Authorizationc放Bearer Token，还需要在头部多传code字段，微信登录后记得保存
 * path: /ranstore/user/miniProgramLogin
 * param: code - {int} 小程序登录code，必填
 * param: phone - {string} 电话号码
 * param: verification_code - {string} 验证码
 */
const miniProgramLogin = (data) => {
  return service({
    method: "post",
    url: "/ranstore/user/miniProgramLogin",
    data
  });
};
export default {
  getUserInfo,
  updateUserInfo,
  getPostObjectParams,
  getPhoneInfo,
  sendVerificationCode,
  miniProgramLogin,
};
